// 导入：类型、接口、模块、组件、样式
import { Component } from "react";

// 登录、跳转到首页
// 清除定时器

class Son extends Component {
  componentWillUnmount(): void {
    console.log("子组件卸载了");
  }

  render() {
    return (
      <fieldset>
        <legend>Son</legend>
      </fieldset>
    );
  }
}

interface Props {}
interface State {}
class Index extends Component<Props, State> {
  state = {
    show: true,
  };
  render() {
    const { show } = this.state;
    return (
      <fieldset>
        <legend>21-生命周期：卸载</legend>
        <button onClick={() => this.setState({ show: false })}>隐藏</button>
        {show && <Son />}
      </fieldset>
    );
  }
}
export default Index;
